function waste_electricity()
	ret = 0
	for i = 1, 1000 do ret = ret + math.random() end
	return ret
end

function foo(arg)
	for i = 1, arg.count do
		for j = 1, math.random(arg.low or 2, arg.high or 20) do waste_electricity(j) end
		print(tostring(arg.name) .. ': iteration ' .. i)
	end
end

co1 = coroutine.create(function () foo {count = 20, name = 'joe', low = 2, high = 300} end)
co2 = coroutine.create(function () foo {count = 50, name = 'jimmy', low = 2, high = 50} end)

print(coroutine.status(co1))
print(coroutine.status(co2))

print(co1)
print(co2)

coroutine.resume(co1)
print(coroutine.status(co1))
coroutine.resume(co2)
print(coroutine.status(co2))
